package feedback;

import util.Entity;
import exceptions.CommentTooLongException;
import exceptions.CommentTooShortException;

/**
 * A compound comment which contains a positive comment and a negative comment.
 */
public class FeedbackComment extends Entity {

    private static final long serialVersionUID = 1L;

    private String positive;

    private String negative;

    public FeedbackComment() {
        super();
        // empty constructor
        this.positive = "";
        this.negative = "";
    }

    public FeedbackComment(final String aPositiveComment, final String aNegativeComment) {
        super();
        this.positive = aPositiveComment;
        this.negative = aNegativeComment;
    }

    public String getPositive() {
        return this.positive;
    }

    public void setPositive(final String aPositiveComment) {
        this.validateComment(aPositiveComment);
        this.positive = aPositiveComment;
    }

    public String getNegative() {
        return this.negative;
    }

    public void setNegative(final String aNegativeComment) {
        this.validateComment(aNegativeComment);
        this.negative = aNegativeComment;
    }

    public void validateComment(final String comment) {
        if (comment.length() < 30) {
            throw new CommentTooShortException();
        }
        if (comment.length() > 500) {
            throw new CommentTooLongException();
        }
    }
}
